package com.tuanbiao.models.action;

import com.hzjq.data.entity.BlastDetailEntity;
import com.hzjq.data.entity.BlastEntity;
import com.hzjq.data.hzjq.entity.LogEntity;
import com.hzjq.lib.BlastKool;
import com.tuanbiao.data.callback.OnBaseResultCallback;

import java.util.List;

/**
 * @author abiao
 * @since 2022/4/29 15:09
 */
public interface BlastLogAction {
    /**
     * 查询爆破记录
     *
     * @param pageIndex
     * @param callback
     */
    default void queryBlast(int pageIndex, OnBaseResultCallback<List<BlastEntity>> callback) {
        BlastKool.Companion.loader().db().queryBlast(pageIndex, blastEntities -> {
            callback.onSuccess(blastEntities);
            callback.onFinish();
        });
    }

    /**
     * 删除爆破记录
     *
     * @param entity
     * @param callback
     */
    default void deleteBlast(BlastEntity entity, OnBaseResultCallback<Void> callback) {
        BlastKool.Companion.loader().db().deleteBlast(entity, () -> {
            callback.onSuccess(null);
            callback.onFinish();
        });

    }

    /**
     * 清除爆破记录
     *
     * @param callback
     */
    default void clearBlast(OnBaseResultCallback<Void> callback) {
        BlastKool.Companion.loader().db().clearBlast(() -> {
            callback.onSuccess(null);
            callback.onFinish();
        });
    }


    default void queryBlastLog(OnBaseResultCallback<List<LogEntity>> callback) {
        BlastKool.Companion.loader().db().queryUnBlastLog(logEntities -> {
            callback.onSuccess(logEntities);
            callback.onFinish();
        });
    }

    default void queryBlastLogById(String blastId, OnBaseResultCallback<List<LogEntity>> callback) {
        BlastKool.Companion.loader().db().queryBlastLogById(blastId, logEntities -> {
            callback.onSuccess(logEntities);
            callback.onFinish();
        });
    }

    default void queryBlastDetailById(String blastId, OnBaseResultCallback<BlastDetailEntity> callback) {
        BlastKool.Companion.loader().db().queryBlastDetailById(blastId, blastDetailEntity -> {
            callback.onSuccess(blastDetailEntity);
            callback.onFinish();
        });
    }
}
